﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using FarseerGames.FarseerPhysics;
using FarseerGames.FarseerPhysics.Collisions;
using FarseerGames.FarseerPhysics.Controllers;
using FarseerGames.FarseerPhysics.Dynamics;
using FarseerGames.FarseerPhysics.Factories;
using FarseerGames.FarseerPhysics.Interfaces;
using FarseerGames.FarseerPhysics.Mathematics;

namespace Warlock
{
    /// <summary>
    /// Erweiterung von Sprite mit Farseer Physik
    /// </summary>
    class PhysicsSprite : Sprite
    {
        //Ueberschreibt Position um die Position des Bodys zurueckzugeben
        public override Vector2 Position
        {
            get
            {
                return body.Position;
            }
            set
            {
                body.Position = value;
            }
        }
        public override float Rotation
        {
            get
            {
                return body.Rotation;
            }
            set
            {
                body.Rotation = value;
            }
        }

        protected Body body;
        protected Geom geom;

        public PhysicsSprite()
            : base()
        {
        }
        public PhysicsSprite(Vector2 position)
        {
            if (body == null)
                throw new Exception("Die Position darf erst gesetzt werden, wenn das Body Objekt erstellt wurde, also in der Unterklasse. Benutzen sie den parameterlosen Konstruktor");
            Position = position;
        }
        public override void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            spriteBatch.Draw(Texture, body.Position, null, Color.White, Rotation, RelativeCenter, Scale, SpriteEffects.None, 0.5f);
        }
    }
}